#include "Socket.hpp"
#include"Protocol.hpp"
#include<iostream>
#include<unistd.h>
#include<memory>

#include"TcpServer.hpp"
using namespace std;
using namespace Network;

void HandlerRequest(Socket* sock)   
{
   while(true)
   {
       struct Request req;
       recv(sock->GetSockfd(),&req,sizeof(req),0);
       req.Debug();
   }
}

int main(int argc,char* argv[])
{
    if (argc != 2)
    {
        cout << "Usage:\n     ./udp_echo_server <port>" << endl;
        return 0;
    }

    uint16_t localport = atoi(argv[1]);

    unique_ptr<TcpServer> svr(new TcpServer(localport,HandlerRequest));
    svr->Loop();
    
}
